package com.woniu.controller;


import com.woniu.service.StatisticsService;
import com.woniu.util.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author mzy
 * @time 2021/03/30 17:12:14
 */
@RestController
public class StatisticsController {

    @Autowired
    private StatisticsService statisticsService;
    /**
     * 根据userid查询该用户的预订单的销售信息
     * @param  userId
     * @return 返回满足userid的用户的销售信息
     */
    @PostMapping ("Statistics/findReserveSalesByUserID")
    public ResultVO findReserveSalesByUserID(@RequestBody String userId){
        List<Map<String, String>> reserveSalesByUserID = null;
        try{
            reserveSalesByUserID = statisticsService.findReserveSalesByUserID(Integer.valueOf(userId));
            return ResultVO.success(reserveSalesByUserID);
        }catch (Exception e){
            e.printStackTrace();
            return ResultVO.failure();
        }
    }
    /**
     * 根据userid查询该用户的售出单的销售信息
     * @param userId
     * @return
     */
    @PostMapping ("Statistics/findReserveSellByUserID")
    public ResultVO findReserveSellByUserID(@RequestBody String userId){
        List<Map<String, String>> reserveSellByUserID = null;
        try{
            reserveSellByUserID = statisticsService.findReserveSellByUserID(Integer.valueOf(userId));
            return ResultVO.success(reserveSellByUserID);
        }catch (Exception e){
            e.printStackTrace();
            return ResultVO.failure();
        }
    }
}
